package com.ifood.system.service.impl;

import java.util.List;

import com.ifood.common.core.domain.R;
import com.ifood.common.core.domain.entity.IFoodStoreInfo;
import com.ifood.common.core.domain.vo.StoreSelectVo;
import com.ifood.common.utils.DateUtils;
import com.ifood.system.mapper.IFoodStoreInfoMapper;
import com.ifood.system.service.IIFoodStoreInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 门店信息Service业务层处理
 *
 * @author ifood
 * @date 2024-01-09
 */
@Service
public class IFoodStoreInfoServiceImpl implements IIFoodStoreInfoService {
    @Autowired
    private IFoodStoreInfoMapper iFoodStoreInfoMapper;

    /**
     * 查询门店信息
     *
     * @param id 门店信息主键
     * @return 门店信息
     */
    @Override
    public IFoodStoreInfo selectIFoodStoreInfoById(Long id) {
        return iFoodStoreInfoMapper.selectIFoodStoreInfoById(id);
    }

    /**
     * 查询门店信息列表
     *
     * @param iFoodStoreInfo 门店信息
     * @return 门店信息
     */
    @Override
    public List<IFoodStoreInfo> selectIFoodStoreInfoList(IFoodStoreInfo iFoodStoreInfo) {
        return iFoodStoreInfoMapper.selectIFoodStoreInfoList(iFoodStoreInfo);
    }

    /**
     * 新增门店信息
     *
     * @param iFoodStoreInfo 门店信息
     * @return 结果
     */
    @Override
    public int insertIFoodStoreInfo(IFoodStoreInfo iFoodStoreInfo) {
        iFoodStoreInfo.setCreateTime(DateUtils.getNowDate());
        return iFoodStoreInfoMapper.insertIFoodStoreInfo(iFoodStoreInfo);
    }

    /**
     * 修改门店信息
     *
     * @param iFoodStoreInfo 门店信息
     * @return 结果
     */
    @Override
    public int updateIFoodStoreInfo(IFoodStoreInfo iFoodStoreInfo) {
        iFoodStoreInfo.setUpdateTime(DateUtils.getNowDate());
        return iFoodStoreInfoMapper.updateIFoodStoreInfo(iFoodStoreInfo);
    }

    /**
     * 批量删除门店信息
     *
     * @param ids 需要删除的门店信息主键
     * @return 结果
     */
    @Override
    public int deleteIFoodStoreInfoByIds(Long[] ids) {
        return iFoodStoreInfoMapper.deleteIFoodStoreInfoByIds(ids);
    }

    /**
     * 删除门店信息信息
     *
     * @param id 门店信息主键
     * @return 结果
     */
    @Override
    public int deleteIFoodStoreInfoById(Long id) {
        return iFoodStoreInfoMapper.deleteIFoodStoreInfoById(id);
    }

    @Override
    public R<List<StoreSelectVo>> selectStoreList() {
        List<StoreSelectVo> storeList = iFoodStoreInfoMapper.selectStoreList();

        return R.ok(storeList);
    }
}
